package ifwhilefor;

import java.util.Scanner;

public class N_to_M_numbers_Divisible_By_Both_3_and_5 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        System.out.println("本程序功能为计算n到m之间能够同时被3与5整除的数字");
        System.out.println("请输入n");
        int n = sc.nextInt();
        System.out.println("请输入m");
        int m = sc.nextInt();
        for (int num = n; num <= m; num++) {
            if (num % 3 == 0 && num % 5 == 0) {
                System.out.println(num + "能同时被3与5整除");
                count++;
            }
        }
        System.out.println(n + "到" + m + "中有" + count + "个能同时被3与5整除的数字");
    }
}